home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Daemon / ptObtainPens.c < prev    next >
C/C++ Source or Header  |  1998-10-01  |  2KB  |  102 lines

  1. #include "MP.h"
  2. #include "PatchData.h"
  3.  
  4. extern BOOL   V39;
  5.  
  6. void mpObtainPens(struct PatchData *pd)
  7. {
  8.   UBYTE *str,state=0,done=FALSE;
  9.   WORD num=0,num1=0,num2;
  10.   struct ColorMap *cm;
  11.  
  12.   if(pd->DNode->Flags & SHAREPENS && 
  13.      pd->DNode->LockedPens        && 
  14.      V39)
  15.   {
  16.     
  17.     cm=pd->OpenNode->Screen->ViewPort.ColorMap;
  18.     
  19.     str=pd->DNode->LockedPens;
  20.     
  21.     while(!done)
  22.     {
  23.       if(!*str) done=TRUE;
  24.       
  25.       if(*str>='0' && *str<='9')
  26.       {
  27.         if(state==0)
  28.           state=1;
  29.         num=0;
  30.         while(*str>='0' && *str<='9')
  31.         {
  32.           num*=10;
  33.           num+=*str - '0';
  34.           str++;
  35.         }
  36.         
  37.         switch(state)
  38.         {
  39.           case 1:
  40. #ifdef ADD_DEBUG_CODE  
  41.             if(MPSem->Debug)
  42.             {
  43.               KP("  obtaining pen %ld\n",num);
  44.             }
  45. #endif      
  46.             if(num<256) // 4.50 - bounds check
  47.             {
  48.               if(!pd->OpenNode->ObtainedPens[num])
  49.               {
  50.                 if(-1!=ObtainPen(cm,num,0,0,0, PEN_EXCLUSIVE | PEN_NO_SETCOLOR))
  51.                   pd->OpenNode->ObtainedPens[num]=1;
  52.               }
  53.             }
  54.             break;
  55.           case 2:
  56.             if(num1>num)// 4.50
  57.             {
  58.               LONG dummy;
  59.               
  60.               dummy=num1;
  61.               num1=num;
  62.               num=dummy;
  63.             }
  64.             
  65.             for(num2=num1+1;num2<=num;num2++)
  66.             {
  67. #ifdef ADD_DEBUG_CODE  
  68.               if(MPSem->Debug)
  69.               {
  70.                 KP("  obtaining pen %ld\n",num2);
  71.               }
  72. #endif
  73.               if(num2<256)// 4.50
  74.               {
  75.                 if(!pd->OpenNode->ObtainedPens[num2])
  76.                 {
  77.                   if(-1!=ObtainPen(cm,num2,0,0,0, PEN_EXCLUSIVE | PEN_NO_SETCOLOR))
  78.                     pd->OpenNode->ObtainedPens[num2]=1;
  79.                 }
  80.               }
  81.             }
  82.             break;
  83.         }
  84.         state=0;
  85.        
  86.       }
  87.       
  88.       if(*str==' ')
  89.         for(;*str==' ';str++);
  90.       else
  91.         if(*str=='-')
  92.         {
  93.           num1=num;
  94.           state=2;
  95.           str++;
  96.         }
  97.         else
  98.           str++;
  99.     }
  100.   }
  101. }
  102.